import { findAllCategory } from '@/api/category'

import { topCategory } from '@/api/caonstants'

export default {
  namespaced: true,
  state: {
    cateList: topCategory.map(v => {
      return {
        name: v
      }
    })
  },
  mutations: {
    setCateList (state, newCateList) {
      state.cateList = newCateList
      // console.log(newCateList)
    }
  },
  actions: {
    async getCateList (context) {
      const res = await findAllCategory()
      // console.log(res.result)
      context.commit('setCateList', res.result)
    }
  }
}
